/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.wii.elpro.dao.jpa;

import com.wii.elpro.dao.JPAUtil;
import com.wii.elpro.dao.ProjectDAOInterface;
import com.wii.elpro.entity.Project;
import java.util.List;
import javax.persistence.EntityManager;

/**
 *
 * @author hendro
 */
public class ProjectDAOImpl extends DAOGenericImpl implements ProjectDAOInterface{

    public Project getProject(long id) throws Exception {
        JPAUtil.beginTransaction();
        EntityManager em = JPAUtil.getEntityManager();
        try {
            return em.find(Project.class, id);
        } catch (Exception ex) {
            throw ex;
        }
    }

    public List<Project> getProjects() throws Exception {
        JPAUtil.beginTransaction();
        EntityManager em = JPAUtil.getEntityManager();
        try {
            return em.createQuery("SELECT d FROM Project d").getResultList();
        } catch (Exception ex) {
            throw ex;
        }
    }

}
